SELECT  *
FROM    (SELECT *,
                ROW_NUMBER() OVER (ORDER BY 1) AS RowNumber
         FROM   (SELECT 1
                ) _
        ) _
WHERE   RowNumber BETWEEN @start AND @finish
ORDER BY RowNumber;

SELECT  COUNT(*)
FROM    (SELECT 1
        ) _;





SELECT  Name
FROM    Tags
WHERE   Id IN (SELECT   Id
               FROM     UserTagTotals
               WHERE    UserId = @userId
                        AND TotalAnswerScort > @tagScoreRequiredToVote)



SELECT  TagSynonyms.Id, SourceTagName, TargetTagName, OwnerUserId, ApprovalDate, TagSynonyms.CreationDate,
        AutoRenameCount, Score, SourceTags.Id AS SourceTagId, TargetTags.Id AS TargetTagId, Users.DisplayName
FROM    TagSynonyms
        LEFT JOIN Tags SourceTags ON SourceTagName = SourceTags.Name
        LEFT JOIN Tags TargetTags ON TargetTagName = TargetTags.Name
        LEFT JOIN Users ON Users.Id = OwnerUserId
WHERE   1 = 1
		AND ApprovalDate IS NOT NULL
		AND ApprovalDate IS NULL
		AND TargetTagName IN (1)
		AND ApprovalDate IS NOT NULL AND ISNULL(SourceTags.[Count], 0) > 0
		AND (SourceTagName LIKE @search OR TargetTagName LIKE @search)
ORDER BY
		CreationDate DESC

ORDER BY
		TargetTagName ASC, AutoRenameCount DESC

ORDER BY
		SourceTagName ASC, AutoRenameCount DESC

ORDER BY
		Score DESC, TargetTagName ASC, AutoRenameCount DESC

ORDER BY
		DisplayName

ORDER BY
		AutoRenameCount DESC, TargetTagName


SELECT  Id, CreationDate
FROM    Post
WHERE   1 = 1
		AND CreationDate >= @date



CREATE PROCEDURE SP1 @x NVARCHAR(MAX), @y INT
AS 
    SELECT TOP 3
			Id, CreationDate
    FROM    Post



